package org.simplextensions;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public abstract class Utils {

    public static String[] merge(String[] depends, String... smvsFM) {
        Set<String> dependsSet = new HashSet<String>();

        if (depends != null)
            for (String s : depends) {
                if (s != null && !s.equals(""))
                    dependsSet.add(s);
            }

        if (smvsFM != null)
            for (String s : smvsFM) {
                if (s != null && !s.equals(""))
                    dependsSet.add(s);
            }

        return dependsSet.toArray(new String[dependsSet.size()]);
    }


    private static Map<String, Integer> sequences = new HashMap<String, Integer>();

    public static synchronized Integer getSequenceValue(String substring) {
        Integer integer = sequences.get(substring);
        if (integer == null) {
            integer = 0;
        }
        sequences.put(substring, ++integer);
        return integer;
    }
}
